<link rel="stylesheet" type="text/css" href="{$basePath}/css/MyFontsWebfontsOrderM3004233.css" />
<link rel="stylesheet" media="screen,projection,tv" href="{$basePath}/systemApps/celebriogallery/default.css" type="text/css" />
<link rel="stylesheet" type="text/css" href="{$basePath}/css/jquery-ui/normal/default.css" />
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>
<script type="text/javascript" src="{$basePath}/js/libs/jquery-ui.js"></script>
<script type="text/javascript" src="{$basePath}/js/apps/jquery-ajax.js"></script>
<script type="text/javascript" src="{$basePath}/js/libs/dragback.js"></script>
<script type="text/javascript" src="{$basePath}/js/libs/celebrioIscroll-lite.js"></script>


<script type="text/javascript">
$(document).ready(function(){
//	if (typeof document.body.onselectstart!="undefined")
//	    document.body.onselectstart=function(){ return false }
//	else if (typeof document.body.style.MozUserSelect!="undefined")
//	    document.body.style.MozUserSelect="none";
//	$(document.body).bind("contextmenu", function(e) {
//           e.preventDefault();
//	    return false;
//       });
	
	$("#celebrioGalleryApp_menu").css({"position" : "absolute", "left" : "-10000"});
	$("#celebrioGalleryApp_contents").css({"position" : "absolute", "left": "-10000"});
	$("#celebrioGalleryApp_menuitems").css("fontSize", (($(window).height() / 100) * 4.2));
	
	$("button").button();
	$("#celebrioGalleryApp_progressbar_text").css({
		"position" : "absolute",
		"top" : "50%",
		"width" : "100%",
		"fontSize" : "50px",
		"margin-top" : "-30px"
	});

	$("#celebrioGalleryApp_progressbar").progressbar({"value" : 37});
	$(".ui-progressbar-value").css({
		"background-image" : "url(" +{$basePath}+ "/css/jquery-ui/normal/images/progress-bar-indeterminate.gif)",
		"-moz-background-size" : "auto 100px",
		"background-size" : "auto 100px"
	});
	
	var swap = true;
	$("#celebrioGalleryApp_menu img").click(function() {
		if(!swap) {
			$("#celebrioGalleryApp_menu img").css({"MozBorderRadius":"0px 10px 10px 0px", "WebkitBorderRadius" : "0px 10px 10px 0px","borderRadius": "0px 10px 10px 0px"});
			swap = true;
			$("#celebrioGalleryApp_menuitems").toggle("slide",{"direction" : "right"},500);
		} else {
			$("#celebrioGalleryApp_menuitems").toggle("slide",{"direction" : "right"},500, function(){
				$("#celebrioGalleryApp_menu img").css({"MozBorderRadius":"10px 10px 10px 10px", "WebkitBorderRadius" : "10px 10px 10px 10px","borderRadius": "10px 10px 10px 10px"});
				swap = false;
			});
		}
	});

	var width = 0;  
	//taka ojebavka zo starej verzie, radsej to tu necham, ale nepouzivat ! 
	/*function checkWidth() {
		if(width == samplesWidthCounter()) {
			setTimeout(checkWidth, 100);
		} else {
			$("#celebrioGalleryApp_samples").css({"width" : samplesWidthCounter()});
			width = samplesWidthCounter();
		}
	}*/

    $(window).resize(function(){
        //setTimeout(checkWidth,100); //width is dependant on loading of default.phtml pictures - more pictures = more time 
		$("#celebrioGalleryApp_menuitems").width($("#celebrioGalleryApp_menu").width() - $("#celebrioGalleryApp_menu img").width()-1);
		$("#celebrioGalleryApp_menuitems").css("fontSize", (($(window).height() / 100) * 4.2));
	});
	
    $(window).load(function(){
    	$("#celebrioGalleryApp_menuitems").width($("#celebrioGalleryApp_menu").width() - $("#celebrioGalleryApp_menu img").width()-1);
    	$("#celebrioGalleryApp_progressbar").remove();
    	$("#celebrioGalleryApp_menu").css({"position" : "absolute", "left": "0", "display": "none"});
    	$("#celebrioGalleryApp_menu").fadeIn("slow");
    	$("#celebrioGalleryApp_contents").css({"left": "0", "display": "none"});
    	$("#celebrioGalleryApp_contents").fadeIn("slow");
    	$("#celebrioGalleryApp_samples").unwrap();
    });
    
    $("#home").click(function(event){
    	celebriogalleryappLink({link Default:default});
    });

    $("#uploadPhotos").click(function(event){
    	celebriogalleryappLink({link Default:savePage});
    });

    $("body").mouseleave(function(){
    	$("#celebrioGalleryApp_contents").mouseup();
    });

    $("#celebrioGalleryApp_contents").mouseleave(function(){
    	$("#celebrioGalleryApp_contents").mouseup();
    });

    $(window).mousemove(function(e){
        if(e.pageX <= 50 || e.pageX >= ($(window).width()-50)) {
    		$("#celebrioGalleryApp_contents").mouseup();
        }
    });
});

var dragging = false;
//class must be created like "celebrioGalleryApp_ + item". Item can be sample, photo, image, etc.
function resizer(item, width){ 
	// Internet Explorer conditional settings !!! DO NOT REMOVE !!!
	/*@cc_on
		$(".celebrioGalleryApp_" + item).height(($("#celebrioGalleryApp_contents").height()/100) * 94);
		//$(".celebrioGalleryApp_" + item).width(width + "%");
    	var counter = 0;
		$(".celebrioGalleryApp_" + item + " img").each(function() {
			counter++;
			$("#" + item + counter + "_description").height(($(".celebrioGalleryApp_" + item).height()/ 100) * 10);
			$(this).height(($(".celebrioGalleryApp_" + item).height()/ 100) * 90);
							
		});
		$("#celebrioGalleryApp_menuitems button").each(function() {
			$(this).height($("#celebrioGalleryApp_menuitems").height());			
		});
	@*/	
		
	$(".celebrioGalleryApp_" + item + "_description").css("fontSize", (($(".celebrioGalleryApp_" + item).height() / 100) * 7));
	$(".celebrioGalleryApp_" + item).width(($(window).width() /100) * width);
	$(".celebrioGalleryApp_" + item).css({"margin-left" :($(window).width() /100), "margin-right" : ($(window).width() /100)});
	$("#" + item + "1").css({"margin-left" :(($(window).width() /100)*1.5)});
	positionHandler(item);
}

var myScroll;
function iScrollLoad() {
	myScroll = new iScroll('celebrioGalleryApp_contents', {
		snap: false,
		momentum: true,
		vScrollbar: false,
		hScrollbar: false,
		vScroll : false
	});
}

function positionHandler(item) {
	var width = 0;
	var counter = 0;
	$(".celebrioGalleryApp_" + item).each(function(){
    	counter++;
       	$("#" + item + + counter).css({"left" : width});
       	width += ($(".celebrioGalleryApp_" + item).width()) + (($(window).width() / 100) * 2);
       	if(counter==1)
        	width+=($(window).width() / 100) * 0.5;
	});
}

function widthCount(item) {
   	var width = 1;
   	$(".celebrioGalleryApp_" + item).each(function(){
   		width += ($(this).width()) + (($(window).width() /100) * 2);
	});
    width += (($(window).width() /100) * 1);
    return width;
}

function celebriogalleryappLink(url) {
	$.getJSON(url, {}, function (payload) {
	    $("#celebrioGalleryApp_contents").html(payload.snippets["snippet--celebriogalleryappSnippet"]);
	});
}
</script>

<div id="celebrioGalleryApp_progressbar">
	<div id="celebrioGalleryApp_progressbar_text">Celebrio Gallery is loading...</div>
</div>

<div id="celebrioGalleryApp_contents">
{snippet celebriogalleryappSnippet}@{include #content}{/snippet}
</div>

<div id="celebrioGalleryApp_menu">
	<img src="{$basePath}/images/seniors/Gallery.png" />
	<div id="celebrioGalleryApp_menuitems">
		<div class="celebrioGalleryApp_menu_content" id="home">
			<button type="button">{!_"Home"}</button>
		</div>
		<div class="celebrioGalleryApp_menu_content" id="uploadPhotos">
			<button type="button">{!_"Upload photos"}</button>
		</div>
	</div>
</div>